package com.song.BeanFactoryTest;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description: UserServiceImplBean：类描述
 * @author: songzhangyong
 * @Date: 2019/11/4 10:31
 */


/**
	如果实现了FactoryBean接口，则当前的对象在sprng中会有两个对象
	1、getObject 返回的对象
	2、当前类的对象

   (UserServiceImplBean) acont.getBean("&userServiceImplBean") 获取的是当前的对象，也就是beanname前面需要加上一个 “&”
   (UserServiceImplBean2) acont.getBean("userServiceImplBean") 获取的是getObject返回的对象。这里没有 “&”

 */
@Service
public class UserServiceImplBean implements FactoryBean , IUserServiceIFactoryBean{

	@Autowired
	private UserServiceImplBean2 userServiceImplBean2 ;

	@Override
	public Object getObject() throws Exception {
		return userServiceImplBean2 ;
	}

	@Override
	public Class<?> getObjectType() {
		return UserServiceImplBean2.class;
	}

	@Override
	public boolean isSingleton() {
		return false;
	}


	@Override
	public void factoryBeanTest(){
		System.out.println("FactoryBean -- test -- ");
	}

}
